<%@ page import="com.example.cdpbookstore.pojo.entity.Category" %>
<%@ page import="java.util.List" %>
<%@ page import="com.example.cdpbookstore.service.CategoryService" %>
<%@ page import="com.example.cdpbookstore.service.impl.CategoryServiceImpl" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
    CategoryService categoryService = new CategoryServiceImpl();
    List<Category> list = categoryService.list();
    pageContext.setAttribute("list", list);
%>

<!-- top bar 部分 -->
<div class="topBar">
    <div class="tb-center">
        <div class="tb-left">
            <p>布克书店</p>
            <c:if test="${customer == null}">
                <a href="login.jsp">请登录</a>
                <a href="register.jsp">免费注册</a>
            </c:if>
            <c:if test="${customer != null}">
                <span>欢迎您，${customer.username}</span>
                <a href="logout">退出登录</a>
            </c:if>

        </div>
        <div class="tb-right">
            <a href="shopping-cart.jsp">购物车</a>
            <a href="order.jsp">我的订单</a>
            <a href="user.jsp">我的账户</a>
        </div>
    </div>
</div>

<!-- search bar 部分 -->
<div class="searchBar">
    <div class="sb-center">
        <div class="logo">
            <a href="index.jsp">
                <img src="image/logo.png" alt="">
            </a>
        </div>
        <div class="searchArea">
            <form action="index.jsp" method="get">
                <input name="search" class="sb-area" placeholder="布克图书搜索">
                <input class="sb-button" type="submit" value="搜索">
            </form>

        </div>
    </div>
</div>

<!-- nav category 部分 -->
<div class="navCategory">
    <div class="nc-center">
        <ul>
            <li><a href="index.jsp"><i class="fa-solid fa-house"></i>首页</a></li>
            <c:forEach var="category" items="${list}">
                <li><a href="index.jsp?category=${category.id}">${category.name}</a></li>
            </c:forEach>
        </ul>
    </div>
</div>